const mongoose = require('mongoose');
// 创建表结构
/* 
   itemName 商品名字
  itemDesc 商品描述
  itemPrice 价格
  itemStore 库存
  onSale 上下架
  thumb 封面图片
  createAt 上架时间
  content  详情内容
*/
const itemSchema = new mongoose.Schema({
  itemName: {
    type: String,
    required: true
  },
  itemDesc: String,
  itemPrice: {
    type: Number,
    required: true
  },
  itemStore: {
    type: Number,
    default: 0
  },
  onSale: {
    type: Number, // 0上架 1下架
    default: 0
  },
  createAt: {
    type: String,
    required: true
  },
  thumb: String,
  content: String
})

// 创建商品表
const itemModel = mongoose.model('qf_items', itemSchema);

module.exports = itemModel;